import bcrypt

# 生成admin123的密码hash
password = "admin123"
salt = bcrypt.gensalt(rounds=12)
hashed = bcrypt.hashpw(password.encode("utf-8"), salt)
hashed_str = hashed.decode("utf-8")

print(f"Password: {password}")
print(f"Hashed: {hashed_str}")
print(f"Length: {len(hashed_str)}")

# 验证
is_valid = bcrypt.checkpw(password.encode("utf-8"), hashed)
print(f"Verification: {is_valid}")

# 生成SQL语句
print("\n=== SQL to update password ===")
print(f"UPDATE sys_user SET password = '{hashed_str}' WHERE username = 'admin';")
